#! /bin/sh

if [ $# -ne 1 ]; then
  echo "Usage: nest_indirect <script>"
  exit 1
fi

abspath="$(cd "${0%/*}" 2>/dev/null; echo "${PWD}/${0##*/}")"
path="$(dirname "${abspath}")"

binary="$("${path}/sli" -c "($1) nest_indirect =")"
exitcode=$?

if [ $exitcode -ne 0 ]; then
  echo "$binary"
  exit $exitcode
fi

echo "Running $binary"
sh -c "$binary"
exit $?
